﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ThucThe;
using System.Data;

namespace KetNoi
{
    public class VanTai_ketnoi
    {
        clsKetNoi kn = new clsKetNoi();
        public DataTable danhSachVanTai()
        {
            return kn.LayDuLieu("VanTai_load");
        }
        public int Them_VanTai(VanTai_thucthe vt)
        {
            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenVanTai"; value[0] = vt.TenVanTai;
            name[1] = "@loaiHinh"; value[1] = vt.LoaiHinh;
            name[2] = "@moTa"; value[2] = vt.MoTa;
            name[3] = "@sdt"; value[3] = vt.Sdt;
            name[4] = "@email"; value[4] = vt.Email;
            return kn.CapNhat("VanTai_them", name, value, Nparameter);
        }
        public int Sua_VanTai(VanTai_thucthe vt)
        {
            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maVanTai"; value[0] = vt.MaVanTai;
            name[1] = "@tenVanTai"; value[1] = vt.TenVanTai;
            name[2] = "@loaiHinh"; value[2] = vt.LoaiHinh;
            name[3] = "@moTa"; value[3] = vt.MoTa;
            name[4] = "@sdt"; value[4] = vt.Sdt;
            name[5] = "@email"; value[5] = vt.Email;
            return kn.CapNhat("VanTai_sua", name, value, Nparameter);
        }
        public int Xoa_VanTai(VanTai_thucthe vt)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maVanTai";
            value[0] = vt.MaVanTai;
            return kn.CapNhat("VanTai_xoa", name, value, Nparameter);
        }
        public DataTable timVanTai(VanTai_thucthe vt)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenVanTai";
            value[0] = vt.TenVanTai;
            return kn.TimKiem("VanTai_tim", name, value, Nparameter);
        }
    }
}
